/*
 * @Author: Liu
 * @Date: 2023-05-08 16:39:44
 * @LastEditTime: 2023-05-16 10:52:41
 */
import vueCookies from 'vue-cookies';
import api from "../axios/index";
import utils from "../utils";

// 登录
export const login = (params) => {
    return api.post("/user/login", params);
}

// 获取用户信息
export const getUserData=()=>{
    return api.get("/user/info",{
        headers: {
            'X-CSRF-TOKEN': vueCookies.get('csrf_access_chess_1025_token'),
            'content-type': 'multipart/form-data'
        }
    })
}

// 查询游戏排行榜
export const getRankingList = () =>{
    return api.get("/user/rank/list")
}

// 人机验证校验
export const userAuth = (data) => {
    // return api.post("/chess823api/user/user_auth", data);
    return api({
        url: '/user/user_auth_v2',
        method: 'post',
        data,
        headers: {
            'X-CSRF-TOKEN': vueCookies.get('csrf_access_chess_1025_token'),
            'content-type': 'multipart/form-data'
        }
    })
}

// 游戏开始
export const gameStart = () =>{
    // return api.post("/chess823api/user/game/start")
    return api({
        url: '/user/game/start',
        method: 'post',
        headers: {
            'X-CSRF-TOKEN': vueCookies.get('csrf_access_chess_1025_token')
        }
    })
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve({
                "data": {
                    "id": 304
                },
                "error_code": 0,
                "msg": "ok",
                "request": "POST /chess1025api/user/game/start"
            })
        }, 100);
    })
}

// 游戏结束
export const gameEnd = (params) => {
    // return api.post("/chess823api/user/game/end")
    return api({
        url: '/user/game/end',
        method: 'post',
        data: params,
        headers: {
            'X-CSRF-TOKEN': vueCookies.get('csrf_access_chess_1025_token'),
            'content-type': 'multipart/form-data'
        }
    })
    return new Promise((resolve,reject) => {
        setTimeout(() => {
            resolve({
                "data": {
                    "category": 0,
                    "content": null,
                    "draw_share": false,
                    "icon": "https://yinli-qixi-run.varwey.com/2023_ca/chess1025/price/prize-2.png",
                    "id": 6,
                    "name": "\u8c22\u8c22\u53c2\u4e0e",
                    "today_remain_draw_num": 0
                },
                "error_code": 0,
                "msg": "ok",
                "request": "POST /chess1025api/user/game/end"
            })
        }, 100);
    })
}

// 查询剩余次数
export const gameTimes = () =>{
    return api.get("/user/game/num")
}

//抽奖

export const lottery = () =>{
    return api.post("/java-api/for520/lottery?activityId=520")
}

// 我的奖品
export const getGifts = (data) =>{
    return api.get("user/gifts",{
        params:data
    })
}

// 奖品信息
export const weekGift = (data) =>{
    return api.get("/user/week/gift")
}

// 奖品信息
export const getScore = (data) =>{
    return api.get("/user/score")
}

// 分享
export const shareRecord = (data) =>{
    return api.get("/user/share")
}
// 检测活动时间
export const userActivity = (data) =>{
    return api.get("/user/activity")
}


// 中奖海报加字上传
export const submitUserPoster = (params,id) =>{   
    // console.log(api.options)
    return api({
        url: '/java-api/for520/upload/submitUserPoster?id='+ id,
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded '
         }, 
        data: params
      })
    // return api.post("/java-api/for520/submitUserPoster",{...params})
}

// 查询用户的中奖海报
export const getPosterUrl = (data) =>{
    return api.get("/java-api/for520/getPosterUrl",{
        params:data
        
    })
}

// 转发获得抽奖机会

export const share = (params) =>{
    return api.post("/java-api/for520/share?activityId=520")
}



